package testing;

import app.*;

import java.io.File;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class AddRecipeTest {
	static Cookbook cookbook = new Cookbook();
	
	public static void main(String[] args) throws SQLException, ClassNotFoundException {
		ArrayList<Ingredient> ingredients = new ArrayList<Ingredient>();
		ingredients.add(new Ingredient("one", (float)5.1, Measurement.JIGGER));
		String file = "newer";
		Recipe recipe = new Recipe("new Test Name", ingredients, "snoitcerid", 5, 20, file, true, 2, cookbook.pullCategory(2));
		
		//cookbook.addRecipeToDB(recipe);
		//testFindMeasurement();
		//testSearchByCategory();
		//testSearchByIngredient();
		//testCreateRecipeFromDB();
		testSearchByFavorites();
		testSortedList();
	}
	private static void testFindMeasurement()
	{
		Measurement testM = cookbook.findMeasurementByAbbrv("lb");
		System.out.println(testM);
	}
	
	private static void testSearchByIngredient() throws SQLException
	{
		List<Recipe> testRecipes = cookbook.searchRecipeByIngredient("one", 0);
		for (Recipe r : testRecipes)
		{
			System.out.println(r);
		}
	}
	
	private static void testCreateRecipeFromDB() throws ClassNotFoundException
	{
		Recipe recipe = cookbook.createRecipeFromDB(9);
		System.out.println(recipe);
	}
	
	private static void testSearchByCategory()
	{		
		ArrayList<Recipe> results = new ArrayList<>(cookbook.searchByCategory(1));
		for ( Recipe r : results)
		{
			System.out.println(r.toString());
		}
	}
	
	private static void testSearchByFavorites() throws SQLException
	{
		List<Recipe> testRecipes = cookbook.searchByFavorite();
		for (Recipe r : testRecipes)
		{
			System.out.println(r);
		}
	}
	
	private static void testSortedList()
	{
		ArrayList<Recipe> testList = cookbook.viewAllRecipes();
		System.out.println( "Sorted List:\n");
		for ( Recipe r : testList )
		{
			System.out.printf( "%s\n", r);
		}
	}

}
